package points

import (
	"context"

	"gorm.io/gorm"
)

type MemberMsg struct {
	NickName  string  `json:"nick_name"`  // 昵称
	Points    float64 `json:"points"`     // 积分
	HeadImg   string  `json:"head_img"`   // 头像
	Phone     string  `json:"phone"`      // 手机号
	ID        string  `json:"id"`         // 用户id
	CardNo    string  `json:"card_no"`    // 会员卡号
	UserToken string  `json:"user_token"` // 会员卡号
}

type PointsInterface interface {
	MemberRegist(ctx context.Context, db *gorm.DB, SalesID, mallID, phone, name string, gender int,
		birthday, idCard, Openid, headImg, provinceId, cityId, areaId, address string) error // 会员注册
	GetMemberInfo(ctx context.Context, db *gorm.DB, SalesID, phone, openid string) (MemberMsg, error)                                               // 会员查询
	PointsConsume(ctx context.Context, db *gorm.DB, salesID, openid, orderID string, tradeAmount float64, mallId string) (err error)                // 会员积分使用
	PointsReverse(ctx context.Context, db *gorm.DB, salesID, openid, refundOrderID, orderID string, tradeAmount float64, mallId string) (err error) // 会员积分冲正
	PointsQuery(ctx context.Context, salesID, openID, mallId string) (points float64, err error)                                                    // 会员积分查询
}

func NewPoints(pointsType string) PointsInterface {
	if pointsType == "1" { // 正弘积分
		return NewZhenghongPoints()
	} else if pointsType == "2" { // 永旺积分
		return NewYongwangPoints()
	} else if pointsType == "3" { // 猫酷积分
		return NewMallcooPoints()
	} else if pointsType == "4" { // 赢商积分
		return NewWinPoints()
	} else if pointsType == "5" { // 万象积分
		return NewWanxiangPoints()
	}
	return nil
}
